#define LOG_TAG "AudioNetIPCP"
#define LOG_NDEBUG 0

#include "convertFromIPCPValue.h"
#include "AudioProtocol.h"
#include <log/log.h>
#include "ap/AudioSignalID.h"



namespace ecarx::transfer::utils{
    std::vector<Signal> ipcpDataToSignals(const ipcp::IpcpValue& ipcpValue){
        std::vector<Signal> signals={};
        ALOGD("funtion: %s, service id %d ", __FUNCTION__, ipcpValue.service_id);
        if(ipcpValue.service_id == audioServiceIDSecond ||ipcpValue.service_id == audioServiceIDSecondMock){
            ALOGD("funtion: %s, oper id %d ", __FUNCTION__, ipcpValue.oper_id);
            switch(ipcpValue.oper_id){
                case warnVolLevelID:{
                    WarnVolLevel_SetRequest signal;
                    int bufferLength = (int) sizeof(WarnVolLevel_SetRequest);;
                    if (ipcpValue.payload_len < bufferLength) {
                        bufferLength = ipcpValue.payload_len;
                    }
                    memcpy(&signal, ipcpValue.payload, bufferLength);
                    signals.reserve(1);
                    ALOGD("funtion: %s, ipcpValue.payload %d ,signal.value%d,toString %s", __FUNCTION__, ipcpValue.payload,signal.value,std::to_string(signal.value).c_str());
                    signals.emplace_back(Signal{
                            .signalId=(int32_t)AudioSignalID::warnVolLevel,
                            .value.stringValue = {std::to_string(signal.value)}  });
                }
                break;
            }
        }
        return signals;
    }

}